<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
	<meta charset="UTF-8">
	<title>资讯管理</title>
	<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
	<jsp:include page="../com/header.jsp"></jsp:include>
	<script type="text/javascript" src="../../js/comm/listcomm.js"></script>
	<script type="text/javascript">
	var contentUrl = root + "cms/news/findNewsNEStatusPage";
	var editUrl = 'newsEdit.jsp?id=';
	var operateUrl = root + 'cms/news/operateNewsByIds';
    var cagetoryUrl = root + "cms/category/findShopCategoryNEStatusPage";
	function getfilter(){
		var _jsonFilter = "{";
				if($("#search_title").val() && $("#search_title").val().length > 0){
			_jsonFilter += "'search_LIKE_title':'"+replaceSingleQuote($("#search_title").val())+"',";
		}
				if($("#search_type").val() && $("#search_type").val().length > 0){
			_jsonFilter += "'search_EQ_type':'"+replaceSingleQuote($("#search_type").val())+"',";
		}
				if($("#search_isHot").val() && $("#search_isHot").val().length > 0){
			_jsonFilter += "'search_EQ_isHot':'"+replaceSingleQuote($("#search_isHot").val())+"',";
		}
				if(_jsonFilter != "{"){
			_jsonFilter = _jsonFilter.substring(0,_jsonFilter.length - 1);
		}
		_jsonFilter += "}";
		return _jsonFilter;
	}

    $(document).ready(function () {
        //加载商品分类
        getNewsCategories();

        //添加商品分类选择时间
        $('#search_Type').change(function () {
            //获取下拉框选中项的text属性值
            var selectID = $("#search_Type").find("option:selected").val();
            console.log('option select id:' + selectID);

            dipscontent(getfilter(), contentUrl);
        });

        $( document ).tooltip();
    });
    function getNewsCategories() {
        $.ajax({
            url: cagetoryUrl,
            data: {
                nextPage: 0,
                pageSize: 99999,
                sortData: null,
                jsonFilter:"{'search_EQ_type':'2'}"
            },
            type: 'POST',
            timeout: 7000,
            dataType: 'json'
        }).done(function (data) {
            if (data.code == 1) {
                var _html = "<option value='' selected>请选择</option>";
                for (var i = 0; i < data.object.content.length; i++) {
                    _html += "<option value='" + data.object.content[i].id + "'>" + data.object.content[i].categoryName + "</option>";
                }
                $('#search_type').html(_html);
            } else {
                myAlert(data.message || tipMessage.undefined_msg);
            }
        }).fail(function (jqXHR, textStatus, errorThrown) {
            if (textStatus == "timeout") {
                myAlert(tipMessage.timeout_msg || "请求超时");
            } else {
                myAlert(tipMessage.error_msg);
            }
        });
    }

	</script>
    </head>
    <body>
      <section>
          <div>
              <div class="col-xs-12">
                  <div class="box">
	                  <form id="search_form" class="form-horizontal">
                      	<div class="tabSelect" id="selectHeadId">
                      		<br>
           	            	<div class="form-group  col-md-3 search-form">
        						<label class="col-md-4 control-label controls" for="">标题：</label>
       				 			<div class="col-md-8">
									<input type="text" placeholder="标题" class="form-control input-sm" id="search_title" name="title"/>
								</div>
      						</div>
							<div class="form-group  col-md-3 search-form">
								<label class="col-md-4 control-label controls">商品分类：</label>
								<div class="col-md-8">
									<select name="categoryType" id="search_type"
											class="form-control input-sm"></select>
								</div>
							</div>
      						<div class="form-group  col-md-3 search-form">
        						<label class="col-md-4 control-label controls" for="">是否热点：</label>
       				 			<div class="col-md-8">
									<select class="form-control input-sm" id="search_isHot" name="isHot">
									    <option value="">请选择</option>
										<option value="1">是</option>
										<option value="0">否</option>
									</select>
								</div>
      						</div>
				            <input type="button" value="查询" id="search" class="btn btn-primary searchBtn">
                      	</div>
	                  </form>
                      <div class="box-body table-responsive" style="clear:both;">
                          <input type="button" value="新增" id="addSome" class="btn btn-success">
                          <input type="button" value="编辑" id="updateSome" class="btn btn-info">
                          <input type="button" value="删除" id="deleteSome" class="btn btn-danger">
                      </div>
                      <div class="box-body table-responsive">
                          <table id="example2" class="table table-bordered table-hover">
                              <thead>
                                  <tr>
                                      <th width="30"><input type="checkbox" id="_selectAll" /></th>
          		               		  <th width="80">标题</th>
				               		  <th width="80">类型</th>
				               		  <th width="80">资讯来源</th>
				               		  <th width="80">资讯缩略图</th>
				               		  <%--<th width="80">是否热点</th>--%>
				               		  <th width="80">创建时间</th>
				               		  <th width="80">状态</th>
                                  </tr>
                              </thead>
                              <!-- 表格内容 start -->
                              <tbody id="mycontent"></tbody>
                              <!-- 表格内容 end -->
                          </table>
                          <!-- 分页标签 start -->
                          <div class="row page_big_div" id="displayPage"></div>
                          <!-- 分页标签 end -->
                          <script id="tableContentTmple" type="text/x-jsrender">
								<tr>
									<td><input id="ck_{{:id}}" ckId="{{:id}}" ckStatus="{{:status}}" class="ckSelect" type="checkbox" /></td>
									<td title={{:title}} style="vertical-align:middle; text-align:left;">{{subStrings:title lens=15}}</td>
									<td>{{if categoryVo}}{{:categoryVo.categoryName}}{{/if}}</td>
									<td title={{:source}} style="vertical-align:middle; text-align:left;">{{subStrings:source lens=15}}</td>
									<td>{{if thumbnail}}<img src="../../{{:thumbnail}}" height="40" width="50">{{else}}<img src="" height="40" width="50">{{/if}}</td>
									<%--<td>{{if isHot}}是{{else}}否{{/if}}</td>--%>
									<td>{{:createTime}}</td>
									<td>{{if status==1}}正常{{else status==2}}已发布{{else status==3}}已删除{{else status==-1}}已锁定{{else}}无效{{/if}}</td>
								</tr>
						  </script>
                  </div>
              </div>
          </div>
      </section>
    </body>
</html>